bool isPalindrome(struct ListNode* head){
    if(head==NULL||head->next==NULL)return true;
    int cnt=0,i;
    struct ListNode *p;
    for(p=head;p!=NULL;p=p->next,cnt++);
    int mid=cnt/2;
    for(p=head,i=0;i<mid;p=p->next,i++);
    
    struct ListNode *s=(struct ListNode*)malloc(sizeof(struct ListNode)),*t,*temp;
    s->next=p;
    t=p;
    while(t!=NULL){
        temp=t->next;
        t->next=s;
        s=t;
        t=temp;
    }
    for(i=0,p=head;i<mid;i++,p=p->next,s=s->next){
        if(p->val!=s->val)return false;
    }
    return true;
}

